Make actions minimally introspectable
authorMatthias Clasen <mclasen@redhat.com>
Sat, 22 Jun 2019 01:16:55 +0000 (01:16 +0000)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 22 Jun 2019 02:47:40 +0000 (22:47 -0400)
This will let us autogenerate some docs for
actions, in the future.

docs/reference/gtk/gtk4-sections.txt
gtk/gtkwidget.c
gtk/gtkwidget.h

index 12f15559c3e335958f05e1ecf341638f70ad17cc..cfb88c7efdab880cda8e93849223062db1a3e26f 100644 (file)
@@ -4634,6 +4634,7 @@ GtkWidgetActionSetStateFunc
 GtkWidgetActionGetStateFunc
 gtk_widget_class_install_action
 gtk_widget_class_install_stateful_action
+gtk_widget_class_query_action
 gtk_widget_action_enabled_changed
 gtk_widget_action_state_changed
 
index 4b093bfaa881cd8dc1a6666336c1bbe43c4ba777..c96909a5e08d5ace352a8518816fc6dc40d3702a 100644 (file)
@@ -13563,3 +13563,41 @@ gtk_widget_action_state_changed (GtkWidget  *widget,
   muxer = _gtk_widget_get_action_muxer (widget, TRUE);
   gtk_action_muxer_action_state_changed (muxer, action_name, state);
 }
+
+/**
+ * gtk_widget_class_query_action:
+ * @widget_class: a #GtkWidgetClass
+ * @index_: position of the action to query
+ * @action_name: return location for the action name
+ * @parameter_type: return location for the parameter type
+ * @state_type: return location for the state type
+ *
+ * Queries the actions that have been installed for
+ * a widget class using gtk_widget_class_install_action()
+ * during class initialization.
+ *
+ * Returns: %TRUE if the action was found,
+ *     %FALSE if @index_ is out of range
+ */
+gboolean
+gtk_widget_class_query_action (GtkWidgetClass      *widget_class,
+                               guint                index_,
+                               const char         **action_name,
+                               const GVariantType **parameter_type,
+                               const GVariantType **state_type)
+{
+  GtkWidgetClassPrivate *priv = widget_class->priv;
+
+  if (priv->actions && index_ < priv->actions->len)
+    {
+      GtkWidgetAction *action = g_ptr_array_index (priv->actions, index_);
+
+      *action_name = action->name;
+      *parameter_type = action->parameter_type;
+      *state_type = action->state_type;
+
+      return TRUE;
+    }
+
+  return FALSE;
+}
index d52dff446aaf65c3aa96caec098b67687c2624a2..31161141edd7da050915433b12c4d619cba63d83 100644 (file)
@@ -1084,6 +1084,13 @@ void                    gtk_widget_class_install_stateful_action (GtkWidgetClass
                                                                   GtkWidgetActionSetStateFunc  set_state,
                                                                   GtkWidgetActionGetStateFunc  get_state);
 
+GDK_AVAILABLE_IN_ALL
+gboolean               gtk_widget_class_query_action  (GtkWidgetClass      *widget_class,
+                                                       guint                index_,
+                                                       const char         **action_name,
+                                                       const GVariantType **parameter_type,
+                                                       const GVariantType **state_type);
+
 GDK_AVAILABLE_IN_ALL
 void                    gtk_widget_action_enabled_changed (GtkWidget  *widget,
                                                            const char *action_name,